﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Permissions;
using System.IO;
using FileHelpers;
using System.Data;
namespace DatabaseInsertAndExportLibrary
{
    class CSVAnalyser
    {
        private string path;
        private int startindex;
        private int endindex;

        public CSVAnalyser(string path)
        {
            // TODO: Complete member initialization
            this.path = path;
        }
        public void Analyse(int startIndex, int length)
        {

            StreamReader sr = new StreamReader(path);
            string line = sr.ReadToEnd();
            sr.Close();




            StreamWriter sw = new StreamWriter(path.Substring(0, path.Length - 4) + "fixed.csv");
            sw.WriteLine(line.Substring(startIndex, length));
            sw.Close();
            
        }

        public int getstartindex(string start)
        {
            int startIndex = 0;
            StreamReader sr = new StreamReader(path);
            string line = sr.ReadToEnd();
            startIndex = line.IndexOf(start) + start.Length;
            sr.Close();
            return startIndex;

        }



        public int getendindex(string end)
        {
            int endIndex = 0;
            StreamReader sr = new StreamReader(path);
            string line = sr.ReadToEnd();
            endIndex = line.IndexOf(end);
            sr.Close();
            return endIndex;



        }

       
        
         


    }
}
